package com.chase.framerwork.interceptor;

import org.apache.log4j.LogManager;
import org.apache.log4j.Logger;

import com.chase.framerwork.common.Globle;
import com.chase.framerwork.exception.SessionLostException;
import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.interceptor.AbstractInterceptor;

/**
 * Session拦截器
 * 
 * @Author Chase
 * @Date 2013-11-5
 */
public class SessionInterceptor extends AbstractInterceptor
{
	private static final Logger logger = LogManager.getLogger(SessionInterceptor.class);

	private static final long serialVersionUID = -974129429866051172L;

	@Override
	public String intercept(ActionInvocation invocation) throws Exception
	{
		String result = null;
		try
		{
			result = invocation.invoke();
		}
		catch (SessionLostException e)
		{
			logger.info("session lost");
			result = Globle.SESSON_LOST;
		}

		return result;
	}
}
